package com.cutepeer.notes.dialogs;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.webkit.WebView.FindListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView;

import com.cutepeer.lib.utils.TimeUtils;
import com.cutepeer.libonline.dialogs.ConfigDialog;
import com.cutepeer.libonline.settings.UserSigned;
import com.cutepeer.notes.MainActivity;
import com.cutepeer.notes.R;
import com.cutepeer.notes.databases.NoteDatabaseHanler;


public class DialogEditNote extends DialogFragment implements OnClickListener{


	private static Activity mActivity;
	private ListView lvOptions;
	private ArrayList<String> arrayOptions;
	public static ArrayList<String> arrayListVoiceResults;
	private RelativeLayout layoutListOptions;
	private EditText editNote;


	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		mActivity = activity;
		super.onAttach(activity);
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
		dialog.getWindow().getAttributes().windowAnimations = R.style.dialogAnimZoomInOut;
		dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_HIDDEN);
		dialog.setContentView(R.layout.dialog_write_note);
		dialog.show();

		ImageButton btnDialogLeft =(ImageButton) dialog.findViewById(R.id.ibHeaderLeft);
		ImageButton btnDialogRight = (ImageButton) dialog.findViewById(R.id.ibHeaderRight);
		TextView tvDialogTitle = (TextView) dialog.findViewById(R.id.tvHeaderTitle);

		editNote =(EditText) dialog.findViewById(R.id.editNote);


		btnDialogLeft.setImageResource(R.drawable.ic_back_white);
		btnDialogRight.setImageResource(R.drawable.ic_send_white);
		tvDialogTitle.setText(getString(R.string.dialog_title_note));

		//event

		btnDialogLeft.setOnClickListener(this);
		btnDialogRight.setOnClickListener(this);

		return dialog;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.ibHeaderLeft:
			dismiss();
			break;

		case R.id.ibHeaderRight:
			NoteDatabaseHanler notedb= new NoteDatabaseHanler(mActivity);
			notedb.addNote("1", UserSigned.getUserId(mActivity), editNote.getText().toString() , TimeUtils.getCurrentDateTime(), "2", "3");
			
			break;

		default:
			break;
		}

	}


}


